var e = getApp();

Page({
    data: {
        language: "",
        refund_id: "",
        button_models: "",
        price: "",
        content: "",
        status_name: "",
        reason: "",
        refund_time: "",
        refund_type_name: "",
        alipay_batch_sn: "",
        create_time: "",
        refund_sn: "",
        reject_reason: "",
        is_plugin: "",
        store_id: "",
        supplier_id: "",
        plugin_id: "",
        _options: {},
        remark: "",
        images: [],
        showID: "",
        refund_order_goods: [],
        return_express: null,
        myData: {},
        freight_price: "",
        other_price: "",
        pluginId: "",
        touraroundOrder: {},
        orderId: "",
        refundData: {}
    },
    onLoad: function(e) {
        e.refund_id && this.setData({
            refund_id: e.refund_id
        }), e.pluginid && (this.setData({
            pluginId: e.pluginid
        }), console.log(this.data.pluginId)), this.setData({
            _options: e
        });
    },
    onReady: function() {
        var e = wx.getStorageSync("langIndex");
        this.setData({
            language: e.en
        });
    },
    onShow: function() {
        this._initData(), this._getNetData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    copyexpress_sn: function(e) {
        var t = e.currentTarget.dataset, a = t.data, n = t.msg;
        wx.setClipboardData({
            data: a,
            success: function() {
                wx.showToast({
                    title: n + "已复制"
                });
            },
            fail: function() {
                wx.showToast({
                    title: n + "已复制",
                    icon: "none"
                });
            }
        });
    },
    showMore: function(e) {
        var t = e.currentTarget.dataset.item.value;
        this.data.showID == t ? this.setData({
            showID: ""
        }) : this.setData({
            showID: t
        });
    },
    _initData: function() {
        this.setData({
            button_models: "",
            price: "",
            content: "",
            status_name: "",
            reason: "",
            refund_time: "",
            refund_type_name: "",
            alipay_batch_sn: "",
            create_time: "",
            remark: "",
            images: [],
            refund_sn: "",
            reject_reason: "",
            is_plugin: "",
            store_id: "",
            supplier_id: "",
            plugin_id: ""
        });
    },
    _getNetData: function() {
        var t = this, a = e.getNetAddresss("refund.detail");
        this.data._options && this.data._options.pluginid && "69" == this.data._options.pluginid && (a = e.getNetAddresss("plugin.snatch-regiment.api.refund.detail")), 
        this.data._options && this.data._options.debt && (a = e.getNetAddresss("plugin.debt-shop.frontend.refund-detail.index"), 
        a += "&member_type=" + this.data._options.debt), this.options.plu && "customer-center" == this.options.plu && (a = e.getNetAddresss("plugin.customer-center.frontend.controllers.customer.refund-detail"), 
        a += "&member_id=" + this.options.customerID), "154" == this.data.pluginId && (a = e.getNetAddresss("plugin.travel-around.frontend.refund.refund.detail")), 
        a += "&refund_id=" + this.data.refund_id, e._getNetWork({
            url: a,
            success: function(e) {
                var a = e.data, n = a.data;
                if (1 == a.result) {
                    var i, d, r, s, o, u, l, _, c, f;
                    if (t.setData({
                        button_models: a.data.button_models,
                        price: a.data.price,
                        content: a.data.content,
                        status_name: a.data.status_name,
                        reason: a.data.reason,
                        refund_time: a.data.refund_time,
                        refund_type_name: a.data.refund_type_name,
                        alipay_batch_sn: a.data.alipay_batch_sn,
                        create_time: a.data.create_time,
                        remark: a.data.remark,
                        images: a.data.images || [],
                        refund_sn: a.data.refund_sn,
                        reject_reason: a.data.reject_reason,
                        is_plugin: a.data.is_plugin ? a.data.is_plugin : null,
                        store_id: a.data.store_id ? a.data.store_id : null,
                        supplier_id: a.data.supplier_id ? a.data.supplier_id : null,
                        plugin_id: a.data.plugin_id ? a.data.plugin_id : null,
                        refund_order_goods: a.data.refund_order_goods,
                        return_express: a.data.return_express,
                        freight_price: Number(a.data.freight_price) || 0,
                        other_price: Number(a.data.other_price) || 0,
                        myData: a.data
                    }), console.log(a.data), 154 == t.data.pluginId) t.setData({
                        touraroundOrder: null == n || null === (i = n.order) || void 0 === i ? void 0 : i.has_one_travel_around_order_goods,
                        orderId: null == n || null === (d = n.order) || void 0 === d ? void 0 : d.order_id,
                        images: null == n || null === (r = n.refund) || void 0 === r ? void 0 : r.image_url,
                        refundData: null == n ? void 0 : n.refund,
                        refund_type_name: null == n || null === (s = n.refund) || void 0 === s ? void 0 : s.refund_type_name,
                        reason: null == n || null === (o = n.refund) || void 0 === o ? void 0 : o.reason,
                        content: null == n || null === (u = n.refund) || void 0 === u ? void 0 : u.content,
                        refund_price: null == n || null === (l = n.refund) || void 0 === l ? void 0 : l.price,
                        create_time: null == n || null === (_ = n.refund) || void 0 === _ ? void 0 : _.created_at,
                        price: null == n || null === (c = n.refund) || void 0 === c ? void 0 : c.price,
                        status_name: null == n || null === (f = n.refund) || void 0 === f ? void 0 : f.status_name,
                        remark: n.remark || ""
                    });
                    "" != a.data.refund_address && t._getaddress();
                }
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    gotoNegotiationRecord: function() {
        wx.navigateTo({
            url: "/packageD/member/myOrder/negotiationRecord/negotiationRecord?refund_id=" + this.data.refund_id
        });
    },
    gotoLogistics: function() {
        wx.navigateTo({
            url: "/packageA/member/order/logistics/logistics?from=userReturn&refund_id=" + this.data.refund_id
        });
    },
    _getaddress: function() {
        var t = this, a = e.getNetAddresss("order.refund.return-address");
        a += "&plugins_id=" + (1 == this.data.is_plugin ? this.data.is_plugin : this.data.plugin_id), 
        a += "&store_id=" + this.data.store_id, a += "&supplier_id=" + this.data.supplier_id, 
        a += "&refund_id=" + this.data.refund_id, e._getNetWork({
            url: a,
            success: function(e) {
                var a = e.data;
                1 == a.result && t.setData({
                    address: a.data
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    operation: function(e) {
        var t = e.currentTarget.dataset.btn;
        2 == t.value ? wx.navigateTo({
            url: "../express/express?refund_id=" + this.data.refund_id
        }) : 1 == t.value ? wx.navigateTo({
            url: "/packageD/member/myOrder/refund/refund?order_id=" + this.data.refund_id + "&type=2"
        }) : 3 == t.value ? this._confirm() : 6 == t.value ? 0 == this.data.myData.resend_express_id ? wx.navigateTo({
            url: "/packageE/multiplePackages/multiplePackages?from=resend&id=" + this.data.refund_id
        }) : wx.navigateTo({
            url: "/packageA/member/order/logistics/logistics?from=resend&refund_id=" + this.data.refund_id + "&express_id=" + this.data.myData.resend_express_id
        }) : this._cancleRefund();
    },
    aroundUpdate: function() {
        var e = JSON.stringify(this.data.refundData);
        wx.navigateTo({
            url: "/packageD/member/myOrder/refund/refund?order_id=".concat(this.data.orderId, "&type=4&orderType=travelAround&refundData=").concat(e, "&pluginid=154")
        });
    },
    aroundDel: function() {
        var t = e.getNetAddresss("plugin.travel-around.frontend.refund.refund.cancel");
        t += "&refund_id=" + this.data.refund_id, e._getNetWork({
            url: t,
            success: function(t) {
                var a = t.data;
                1 == a.result ? wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1500,
                    success: function() {
                        setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1500);
                    }
                }) : e.tips(a.msg);
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    _confirm: function() {
        var t = e.getNetAddresss("refund.operation.complete");
        t += "&refund_id=" + this.data.refund_id, e._getNetWork({
            url: t,
            success: function(t) {
                var a = t.data;
                1 == a.result ? wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1500,
                    success: function() {
                        setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1500);
                    }
                }) : e.tips(a.msg);
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    _cancleRefund: function() {
        var t = e.getNetAddresss("refund.operation.cancel");
        t += "&refund_id=" + this.data.refund_id, e._getNetWork({
            url: t,
            success: function(t) {
                var a = t.data;
                1 == a.result ? wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1500,
                    success: function() {
                        setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1500);
                    }
                }) : e.tips(a.msg);
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    preview: function(e) {
        var t = e.currentTarget.dataset.src;
        wx.previewImage({
            current: this.data.images[t],
            urls: this.data.images
        });
    }
});